class Solution {
public:
    const int mod=1e9+7;
    int purchasePlans(vector<int>& nums, int target) {
        sort(nums.begin(),nums.end());
        int n=nums.size();
        int ans=0;
        int left=0;
        int right=n-1;
        while(left<right)
        {
            if(nums[left]+nums[right]>target)
            {
                right--;
            }
            else
            {
                ans=(ans+right-left)%mod;//解的个数是 righr - left
                left++;
            }
        }
        return ans;
    }
};